# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=nginx-mod-redis
pkgver=0.3.9
pkgrel=11

_modname="${pkgname#nginx-mod-}"

pkgdesc='Nginx module for redis caching'
arch=('loong64' 'x86_64')
depends=('nginx')
makedepends=('nginx-src')
url="https://www.nginx.com/resources/wiki/modules/redis/"
license=('CUSTOM')

source=(
	https://people.freebsd.org/~osa/ngx_http_redis-$pkgver.tar.gz
)
validpgpkeys=(B0F4253373F8F6F510D42178520A9993A1C052F8) # Maxim Dounin <mdounin@mdounin.ru>
sha256sums=('21f87540f0a44b23ffa5df16fb3d788bc90803b255ef14f9c26e3847a6f26f46')

build() {
  cp -r /usr/src/nginx .

	cd "$srcdir"/nginx
	./configure --with-compat --add-dynamic-module=../ngx_http_redis-$pkgver
	make modules
}

package() {
	install -Dm644 "$srcdir"/ngx_http_redis-$pkgver/LICENSE \
	               "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

	cd "$srcdir"/nginx/objs
	for mod in *.so; do
		install -Dm755 $mod "$pkgdir"/usr/lib/nginx/modules/$mod
	done
}
